#define _CRT_SECURE_NO_WARNINGS 1
#include <string>
using namespace std;
class Solution {
public:
    bool isUnique(string astr) {
        //优化,鸽巢原理
        if (astr.length() > 26) return false;
        int index = 0;
        for (auto& e : astr)
        {
            int i = e - 'a';
            //判断字符是否已经出现过
            if (((index >> i) & 1) == 1) return false;
            //将字符入位图
            //index |= 1 << i;
            index = (index << i) | 1;
        }
        return true;
    }
};